package com.xxx.blog.controller;

import com.github.pagehelper.PageHelper;
import com.xxx.blog.domain.Param;
import com.xxx.blog.service.IParamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/param")
@Api(tags = "参数接口类")
public class ParamController {
    @Autowired
    private IParamService paramService;

    @GetMapping("/map")
    @ApiOperation(value = "参数map")
    public Map<String,String> map(){
        PageHelper.clearPage();
        List<Param> list = paramService.findAll();

        Map<String,String> map = new HashMap<>();

        for (Param param : list) {
            map.put(param.getParamKey() ,param.getParamValue());
        }

        return map;
    }
}
